package com.example.interview.Thread;

import java.util.HashMap;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:TQ02
 * Data:2024-07-08
 * Time:21:36
 * Text：
 */
public class Synchronzied {
    private Object lock = new Object();
    private int count = 0;

    public void increment() {
        synchronized (lock) {
            count++;
        }
    }

    public int getCount() {
        synchronized (lock) {
            return count;
        }
    }
    private int count2 = 0;

    public synchronized void increment2() {
        count++;
    }

    public synchronized int getCount2() {
        HashMap<Integer,Integer> map =new HashMap<>();
        return count;
    }

}
